#include <iostream>
#include <vector>
#include <algorithm>

int main()
{
    int N;
    std::cin >> N;
    std::vector<int> weights(N, 0);

    int tw = 0;
    for (int i = 0; i < N; i++)
    {
        int w;
        std::cin >> w;
        weights[i] = w;
        tw += w;
    }

    if (tw % 2 == 1)
    {
        std::cout << -1 << std::endl;
        return 0;
    }

    int aw = tw / 2;
    std::vector<int> dp(aw + 1, 1e5);
    dp[0] = 0;
    for (int i = 0; i < N; i++)
    {
        for (int j = aw; j >= weights[i]; j--)
        {
            if (dp[j - weights[i]] != 1e5)
                dp[j] = std::min(dp[j], dp[j - weights[i]] + 1);
        }
    }

    if (dp[aw] >= 1e5)
        std::cout << -1 << std::endl;
    else
        std::cout << dp[aw] << std::endl;

    return 0;
}